using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using RealState.BusinessObjects;

namespace RealState.DAL
{
	public class ImageTypesDAO
	{
		public ImageTypesDAO()
		{
			DbProviderHelper.GetConnection();
		}
		public List<ImageTypes> GetImageTypess()
		{
			try
			{
				List<ImageTypes> lstImageTypess = new List<ImageTypes>();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECTImageTypess",CommandType.StoredProcedure);
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					ImageTypes oImageTypes = new ImageTypes();
					oImageTypes.Id = Convert.ToInt32(oDbDataReader["Id"]);
					oImageTypes.Tile = Convert.ToString(oDbDataReader["Tile"]);
					lstImageTypess.Add(oImageTypes);
				}
				oDbDataReader.Close();
				return lstImageTypess;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public ImageTypes GetImageTypes(int Id)
		{
			try
			{
				ImageTypes oImageTypes = new ImageTypes();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECTImageTypes",CommandType.StoredProcedure);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Id",DbType.Int32,Id));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					oImageTypes.Id = Convert.ToInt32(oDbDataReader["Id"]);
					oImageTypes.Tile = Convert.ToString(oDbDataReader["Tile"]);
				}
				oDbDataReader.Close();
				return oImageTypes;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int AddImageTypes(ImageTypes oImageTypes)
		{
			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("INSERTImageTypes",CommandType.StoredProcedure);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Tile",DbType.String,oImageTypes.Tile));

				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int UpdateImageTypes(ImageTypes oImageTypes)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("UPDATEImageTypes",CommandType.StoredProcedure);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Tile",DbType.String,oImageTypes.Tile));
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Id",DbType.Int32,oImageTypes.Id));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveImageTypes(ImageTypes oImageTypes)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("DELETEImageTypes",CommandType.StoredProcedure);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Id",DbType.Int32,oImageTypes.Id));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveImageTypes(int Id)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("DELETEImageTypes",CommandType.StoredProcedure);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Id",DbType.Int32,Id));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
	}
}
